﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace KingdeePdaService
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            //登入接口
            ConfigDatas.Initial();

            PdaService s = new PdaService();
            //var ee=  s.GetAccounts();


            //获取条码
            //s.GetCodeDetail("5b4bfd8ee0afe5", "lzw", "888888", 2052, "1807282001", "100004", "101268", false);

            //s.GetSaleOrder("5ac97dd9b0c4ca", "001", "123456", 2052, "XSDD000081", "100241");


            #region 销售订单保存测试数据



            #endregion
            #region 生产备料单 测试数据

            //s.ManufactureStock("5b4bfd8ee0afe5", "lzw", "888888", 2052, "SCBL180715", "100004", "101268");

            //DataSet dataS = new DataSet();
            //// 条码
            //Type type = typeof(string);
            //string FPkValue = "SCBL18043";
            //DataTable bindDataSource = new DataTable();
            ////源单单据体主键Id
            //bindDataSource.Columns.Add(new DataColumn("ID", type));
            ////机组
            //bindDataSource.Columns.Add(new DataColumn("生产机组"));
            //bindDataSource.Columns.Add(new DataColumn("FMachine", type));
            //// 条码
            //bindDataSource.Columns.Add(new DataColumn("FBarCode", type));
            //bindDataSource.Columns.Add(new DataColumn("条码", type));
            ////物料编码
            //bindDataSource.Columns.Add(new DataColumn("FMaterialId", type));
            //bindDataSource.Columns.Add(new DataColumn("原纸名称", type));
            ////幅宽编码
            //bindDataSource.Columns.Add(new DataColumn("FAuxPropId", type));
            //bindDataSource.Columns.Add(new DataColumn("幅宽", type));
            ////数量
            //bindDataSource.Columns.Add(new DataColumn("Qty", type));
            //bindDataSource.Columns.Add(new DataColumn("数量", type));
            ////单位
            //bindDataSource.Columns.Add(new DataColumn("UnitId", type));
            //bindDataSource.Columns.Add(new DataColumn("单位", type));

            //s.ProductionStockSave("5a460d781d9047", "001", "123456", 2052, "100004", null);
            #endregion

            #region 盘点作业 测试数据

            //dataS.Tables.Add(ResultsTable);

            //string FId = "100001";
            //Type type = typeof(string);

            //DataSet dataS = new DataSet();
            ////单据体
            //DataTable ResultsTable = new DataTable();
            //ResultsTable.Columns.Add(new DataColumn("ID", type));              //Id
            ////ResultsTable.Columns.Add(new DataColumn("FBarCode", type));        // 条码
            //ResultsTable.Columns.Add(new DataColumn("FMaterialName", type));    //物料名
            //ResultsTable.Columns.Add(new DataColumn("FMaterialNum", type));     //物料编码
            //ResultsTable.Columns.Add(new DataColumn("FMaterialId", type));     //物料Id
            //ResultsTable.Columns.Add(new DataColumn("FAcctQty", type));         //账存数
            //ResultsTable.Columns.Add(new DataColumn("AuxpropNum", type));        //幅宽
            //ResultsTable.Columns.Add(new DataColumn("FDiameter", type));         //芯径
            //ResultsTable.Columns.Add(new DataColumn("FDensity", type));           //密度
            //ResultsTable.Columns.Add(new DataColumn("FUnit", type));              //单位
            //ResultsTable.Columns.Add(new DataColumn("FCountQty", type));          //盘点数


            //string dr1MaNum = "01B0008";string dr2MaNum = "01E0012";string dr3MaNum = "01O0010";string dr4MaNum = "0210006";

            //string dr1AuNum = "100";
            //string dr2AuNum = "105";
            //string dr3AuNum = "110";
            //string dr4AuNum = "90";
            //DataRow dr1 = ResultsTable.NewRow();
            //dr1["ID"] = "100042"; dr1["FMaterialNum"] = dr1MaNum; dr1["AuxpropNum"] = dr1AuNum;
            //DataRow dr2 = ResultsTable.NewRow();
            //dr2["ID"] = "100049"; dr2["FMaterialNum"] = dr2MaNum; dr2["AuxpropNum"] = dr2AuNum;
            //DataRow dr3 = ResultsTable.NewRow();
            //dr3["ID"] = "100050"; dr3["FMaterialNum"] = dr3MaNum; dr3["AuxpropNum"] = dr3AuNum;
            //DataRow dr4 = ResultsTable.NewRow();
            //dr4["ID"] = "0"; dr4["FMaterialNum"] = dr4MaNum; dr4["AuxpropNum"] = dr4AuNum;

            //ResultsTable.Rows.Add(dr1);
            //ResultsTable.Rows.Add(dr2);
            //ResultsTable.Rows.Add(dr3);
            //ResultsTable.Rows.Add(dr4);

            ////子单据体
            //DataTable SubResulteTale = new DataTable();
            //SubResulteTale.Columns.Add(new DataColumn("ID", type));
            //SubResulteTale.Columns.Add(new DataColumn("FID", type));
            //SubResulteTale.Columns.Add(new DataColumn("F_D_BarCode", type));
            //SubResulteTale.Columns.Add(new DataColumn("FMaterialName", type));
            //SubResulteTale.Columns.Add(new DataColumn("FMaterialNum", type));
            //SubResulteTale.Columns.Add(new DataColumn("AuxpropNum", type));
            //SubResulteTale.Columns.Add(new DataColumn("F_D_UnitID", type));
            //SubResulteTale.Columns.Add(new DataColumn("F_D_Qty", type));                  //账存数
            //SubResulteTale.Columns.Add(new DataColumn("F_D_CountQty", type));             //盘点数


            //DataRow row1 = SubResulteTale.NewRow();
            //row1["ID"] = "100003";row1["FID"] = "100042";row1["F_D_BarCode"] = "100042A";row1["FMaterialNum"] = dr1MaNum;row1["AuxpropNum"] = dr1AuNum;row1["F_D_UnitID"] = "kg"; row1["F_D_Qty"] = "1"; row1["F_D_CountQty"] = "2";
            //DataRow row2 = SubResulteTale.NewRow();
            //row2["ID"] = "100004"; row2["FID"] = "100042"; row2["F_D_BarCode"] = "100042B"; row2["FMaterialNum"] = dr1MaNum; row2["AuxpropNum"] = dr1AuNum; row2["F_D_UnitID"] = "kg"; row2["F_D_Qty"] = "3"; row2["F_D_CountQty"] = "4";
            //DataRow row3 = SubResulteTale.NewRow();
            //row3["ID"] = "100005"; row3["FID"] = "100042"; row3["F_D_BarCode"] = "100042C"; row3["FMaterialNum"] = dr1MaNum; row3["AuxpropNum"] = dr1AuNum; row3["F_D_UnitID"] = "kg"; row3["F_D_Qty"] = "5"; row3["F_D_CountQty"] = "6";
            //DataRow row4 = SubResulteTale.NewRow();
            //row4["ID"] = "0"; row4["FID"] = "100042"; row4["F_D_BarCode"] = "100042D"; row4["FMaterialNum"] = dr1MaNum; row4["AuxpropNum"] = dr1AuNum; row4["F_D_UnitID"] = "kg"; row4["F_D_Qty"] = "7"; row4["F_D_CountQty"] = "8";

            //DataRow X = SubResulteTale.NewRow();
            //X["ID"] = "0"; X["FID"] = "100050"; X["F_D_BarCode"] = "100050A"; X["FMaterialNum"] = dr3MaNum; X["AuxpropNum"] = dr3AuNum; X["F_D_UnitID"] = "kg"; X["F_D_Qty"] = "1"; X["F_D_CountQty"] = "2";

            //DataRow Z = SubResulteTale.NewRow();
            //Z["ID"] = "0"; Z["FID"] = "100050"; Z["F_D_BarCode"] = "000000A"; Z["FMaterialNum"] = dr4MaNum; Z["AuxpropNum"] = dr4AuNum; Z["F_D_UnitID"] = "g"; Z["F_D_Qty"] = "1"; Z["F_D_CountQty"] = "2";

            //SubResulteTale.Rows.Add(row1);
            //SubResulteTale.Rows.Add(row2);
            //SubResulteTale.Rows.Add(row3);
            //SubResulteTale.Rows.Add(row4);
            //SubResulteTale.Rows.Add(X);
            //SubResulteTale.Rows.Add(Z);
            //dataS.Tables.Add(ResultsTable);
            //dataS.Tables.Add(SubResulteTale);


            //s.InventorySave("5a460d781d9047", "001", "123456", 2052, FId, dataS);

            //s.InquiryBillNo("5a460d781d9047", "001", "123456", 2052,"PDZY000001");
            //s.GetInventoryBill("5a460d781d9047", "001", "123456", 2052, "100001", "100856");

            #endregion

            #region 无源单测试 测试数据

            //Type type = typeof(string);
            //DataSet dataS = new DataSet();
            //DataTable ResultsTable = new DataTable();
            ////物料编码
            //ResultsTable.Columns.Add(new DataColumn("FMaterialId", type));
            ////物料名
            //ResultsTable.Columns.Add(new DataColumn("FMaterialName", type));
            ////条码
            //ResultsTable.Columns.Add(new DataColumn("FBarCode", type));
            ////基本数量
            //ResultsTable.Columns.Add(new DataColumn("FBaseQty", type));
            ////基础单位
            //ResultsTable.Columns.Add(new DataColumn("FBaseUnitId", type));
            ////幅宽
            //ResultsTable.Columns.Add(new DataColumn("FAuxPropId", type));
            ////数据取出保存
            //DataRow drRow = ResultsTable.NewRow();
            //drRow["FMaterialId"] = "0130018";
            //drRow["FMaterialName"] = "Name";
            //drRow["FBarCode"] = "412090105180804014";
            //drRow["FBaseQty"] = "100";
            //drRow["FBaseUnitId"] = "kg";
            //drRow["FAuxPropId"] = "";
            //DataRow drRow2 = ResultsTable.NewRow();
            //drRow2["FMaterialId"] = "01B0008";
            //drRow2["FMaterialName"] = "Name";
            //drRow2["FBarCode"] = "412090105180804015";
            //drRow2["FBaseQty"] = "99";
            //drRow2["FBaseUnitId"] = "kg";
            //drRow2["FAuxPropId"] = "100";
            //ResultsTable.Rows.Add(drRow);
            //ResultsTable.Rows.Add(drRow2);

            //dataS.Tables.Add(ResultsTable);
            ///// <param name="bizType">调拨类型</param>
            ///// <param name="outOrg">调出组织</param>
            ///// <param name="outStock">调出仓库</param>
            ///// <param name="inOrg">调入组织</param>
            ///// <param name="inStock">调入仓库</param>
            ///// <param name="dataS">条码信息</param>

            //测试 直接调拨                                                  InnerOrgTransfer OverOrgTransfer
            //s.SaveSTKTransferDirect("5b4bfd8ee0afe5", "lzw", "888888", 2052, "InnerOrgTransfer", "101", "CK140", "101", "CK004", dataS);
            //测试获取仓库组织 ，仓库
            //s.GetOrgStock("5a460d781d9047", "001", "123456", 2052);
            //测试登录
            //s.Login("5a460d781d9047", "001", "123456", 2052);


            #endregion

        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}